﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wjtour.Common;
using Hjp.FrameWork.Common;

namespace Wjtour.Web.Front
{
    public partial class memberpassedit : MemberBasePage
    {
        protected TextBox old_password;
        protected TextBox new_password;
        protected TextBox renew_passwd;
        protected Button submit;

        protected void Page_Load(object sender, EventArgs e)
        {
            submit.Click += submit_Click;
        }

        void submit_Click(object sender, EventArgs e)
        {
            Wjtour.BLL.member_bll _bll = new BLL.member_bll();
            if (string.IsNullOrWhiteSpace(old_password.Text))
            {
                Utils.Alert(this.Page, "旧密码不能为空!");
                return;
            }
            if (string.IsNullOrWhiteSpace(new_password.Text))
            {
                Utils.Alert(this.Page, "新密码不能为空!");
                return;
            }
            if (string.IsNullOrWhiteSpace(renew_passwd.Text))
            {
                Utils.Alert(this.Page, "确认密码不能为空");
                return;
            }
            if (new_password.Text != renew_passwd.Text)
            {
                Utils.Alert(this.Page, "两次的密码不一致！");
                return;
            }

            if (old_password.Text == CurrentMember.pwd)
            {
                CurrentMember.pwd = renew_passwd.Text.Trim();
                bool b = _bll.Save(CurrentMember);
                if (b)
                {
                    Session["CurrentMember"] = _bll.Load(CurrentMember.id);
                    Utils.Alert(this.Page, "密码修改成功！");
                }
            }
        }
    }
}
